<!DOCTYPE html>
<html>
{% load staticfiles %}
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="pragma" content="no-cache">
    <meta name="robots" content="index,follow">
    <meta name="Author" content="reboot">

    <link href="{% static 'img/favicon.ico' %}" type="image/x-icon" rel="shortcut icon">
    <link href="/static/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="{% static 'vendor/alert/sweet-alert.css' %}" rel="stylesheet">
    <style type="text/css">
        body {
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #eee;
        }

        .form-signin {
            max-width: 330px;
            padding: 15px;
            margin: 0 auto;
        }
    </style>

    <title>Devops平台 - 管理员登陆</title>
</head>
<body>
<!--loginbox again-->
<div class="container">
    <form class="form-signin" id="loginform">
        <h2 class="form-signin-heading" style="text-align: center;">用户登录</h2>
        <div class="form-group">
            <input type="text" id="username" class="form-control" name="username"
                                {# 从cookie中取出用户名  #}
                    value="{% if request.COOKIES.username %}{{ request.COOKIES.username }}{% endif %}"
                   placeholder="用户名"/>
        </div>
        <div class="form-group">
            <input type="password" id="password" class="form-control"
                   {# 密码不需要填写 #}
                   value="{% if request.COOKIES.password %}*****{% endif %}"
                   name="password" placeholder="密码"/>
        </div>
        {# 记住密码S  #}
        <div class="form-group">
            <input type="checkbox"  name="remember_pwd" value="1" >
            <label for="checkbox1">记住密码</label>
        </div>

        {# 记住密码E  #}
        <button type="submit" class="btn btn-lg btn-primary btn-block">登录</button>
        <a id='forget'>忘记密码</a>
    </form>
</div>


<script type="text/javascript" src="/static/vendor/alert/sweet-alert.min.js"></script>
<script type="text/javascript" src="/static/vendor/jquery/jquery.min.js"></script>

<script type="text/javascript">
    /* 忘记密码提示*/
    $("#forget").click(function () {
        str = "请联系管理员帮您重置密码" + '\n' + "邮箱：panda@reboot.com"
        swal(str)
    });


    /*用户登录*/
    $('#loginform').on('submit', function () {
        var str = $('#loginform').serialize()
        $.post('#', str, function (res) {
            if (res.status == 0) {
                location.href = res.next_url
            } else {
                swal({
                    title: res.errmsg,
                    type: "error",
                    confirmButtonText: "知道了"
                }, function () {
                    $("#username").val("")
                    $("#password").val("")
                });

            }
        });
        return false;

    })


</script>


</body>
</html>
